package com.qingcheng.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.qingcheng.pojo.seckill.SeckillGoods;
import com.qingcheng.service.seckill.SeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;

/**
 * @author 岳剑飞
 * @Company http://www.ithiema.com
 */
@Service
public class SeckillGoodsServiceImpl implements SeckillGoodsService {
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * Redis 中根据key获取秒杀商品列表
     *
     * @param key
     * @return
     */
    @Override
    public List<SeckillGoods> list(String key) {

        return redisTemplate.boundHashOps("SeckillGoods_" + key).values();

    }

    /**
     * 根据ID查询商品详情
     * @param time
     * @param id
     * @return
     */
    @Override
    public SeckillGoods one(String time, Long id) {
        SeckillGoods seckillGoods = (SeckillGoods) redisTemplate.boundHashOps("SeckillGoods_" + time).get(id);
        return seckillGoods;
    }











}
